<script type="text/javascript" language="javascript"><!--
var zAxisIndicator = 0;
var tmpZAxisIndicator = 0;
var hoveringActivated = true;
var foreground = false;
/**
* Function is called by an ResourceVisualization-Div at event "onclick"
* @param resVisuID the ID of the calling ResourceVisualization
*/
function mouseclickOnResVisu(resVisuID){
	zAxisIndicator += 100;
	$(resVisuID + "_border").setStyle({zIndex:zAxisIndicator});
	foreground = true;
}
/**
* Function is called by an ResourceVisualization-Div at event "onmousedown"
* @param resVisuID the ID of the calling ResourceVisualization
*/
function mouseDownOnResVisu(resVisuID){
//comment this if you don't want to make the resource movable everywhere...
	drag = new Draggable(resVisuID + "_border", {});
	hoveringActivated = false;
}
/**
* Function is called by an ResourceVisualization-Div at event "onmouseup"
* @param resVisuID the ID of the calling ResourceVisualization
*/
function mouseUpOnResVisu(resVisuID, contentID){
	hoveringActivated = true;
	resize3();
	saveResourcePos(resVisuID, contentID);
	if(drag!=null){
		drag.finishDrag(window.event);
		drag.destroy();
	}
}

/**
* Function is called by an ResourceVisualization-Div at event "onmouseover"
* @param resVisuID the ID of the calling ResourceVisualization
*/
function mouseOverResVisu(resVisuID){
	if (hoveringActivated){
		tmpZAxisIndicator = $(resVisuID + "_border").getStyle('zIndex');
		var zAxisForeground = zAxisIndicator + 100;
		$(resVisuID + "_border").setStyle({zIndex:zAxisForeground});
		$(resVisuID + "_menu").setStyle({display:'block'});	
		$(resVisuID + "_tags_container").setStyle({visibility:'visible'});
	}
}
	

/**
* Function is called by an ResourceVisualization-Div at event "onmouseout"
* @param resVisuID the ID of the calling ResourceVisualization
*/
function mouseOutResVisu(resVisuID){
	if (hoveringActivated){
		if (!foreground) {
			$(resVisuID + "_border").setStyle({zIndex:tmpZAxisIndicator});
		}
		foreground = false;
		$(resVisuID + "_menu").setStyle({display:'none'});
		$(resVisuID + "_tags_container").setStyle({visibility:'hidden'}); 
	}
}
		
/**
* Function is called by an ResourceVisualization-Menu-Div on event "onmousedown"
* @param resVisuID the ID of the calling ResourceVisualization
*/
function mouseDownOnResVisuMenu(resVisuID){
	drag = new Draggable(resVisuID + "_border", {});
	hoveringActivated = false;
}
/**
* Function is called by an ResourceVisualization-Menu-Div on event "onmouseup"
* @param resVisuID the ID of the calling ResourceVisualization
*/
function mouseUpOnResVisuMenu(resVisuID, contentID){
	hoveringActivated = true;
	resize3();
	saveResourcePos(resVisuID, contentID);
	if(drag!=null){
		drag.finishDrag(window.event);
		drag.destroy();
	}
}
		
/* Resizing stuff */
var posXResize;
var posYResize;
var mousedown = 0;
var idOfResizedResource;

/**
* Init of resizing. Called by onmousedown().
* @param id the ID of the ResourceVisualization to resize
* @param ResizeEvent the mouseEvent
*/
function resize1(id, ResizeEvent){
	if (mousedown == 1) {return;}
	if(!ResizeEvent){
		ResizeEvent = window.event;
	}
	hoveringActivated = false;
	idOfResizedResource = id;
	mousedown = 1;
	posXResize = ResizeEvent.clientX;
	posYResize = ResizeEvent.clientY;
}
		
/**
* The resizing. Called by onmousemove().
* @param ResizeEvent the mouseEvent
*/
function resize2(ResizeEvent) {
	if (mousedown == 0 || idOfResizedResource == 0) {
		return;
	}
	if(!ResizeEvent){
		ResizeEvent = window.event;
	}
	newXResize = parseInt($(idOfResizedResource + "_border").getWidth()) + ResizeEvent.clientX - posXResize;
	newYResize = parseInt($(idOfResizedResource + "_border").getHeight()) + ResizeEvent.clientY - posYResize;
//	newXcResize = parseInt($(idOfResizedResource + "_resize").getStyle('width')) + ResizeEvent.clientX - posXResize;
	if ($(idOfResizedResource + "_content")){
		newXaResize = parseInt($(idOfResizedResource + "_content").getWidth()) + ResizeEvent.clientX - posXResize;
	}
	if ($(idOfResizedResource + "_contentVideo")){
		newXbResize = parseInt($(idOfResizedResource + "_contentVideo").getWidth()) + ResizeEvent.clientX - posXResize;
		newYbResize = parseInt($(idOfResizedResource + "_contentVideo").getHeight()) + ResizeEvent.clientY - posYResize;
	}
	
	/** constrain resizing*/
	var groupVP = $("group").viewportOffset();
	var groupXStart = groupVP[0];
	var groupYStart = groupVP[1];
	var groupWidth = $("group").getWidth();
	var groupHeight = $("group").getHeight();
	
	var mouseXPos = ResizeEvent.pageX;
	var mouseYPos = ResizeEvent.pageY;

	if(mouseXPos > groupXStart + groupWidth || mouseYPos > groupYStart + groupHeight || mouseXPos < groupXStart || mouseYPos < groupYStart){
		return;
	}
	else{
	
//	$(idOfResizedResource + "_resize").setStyle({width:newXcResize + "px"});
	$(idOfResizedResource + "_border").setStyle({width:newXResize + "px"});
    $(idOfResizedResource + "_border").setStyle({height:newYResize + "px"});
    
    $(idOfResizedResource).setStyle({width:(newXResize-26) + "px"});
    $(idOfResizedResource).setStyle({height:(newYResize-24) + "px"});
    
	if ($(idOfResizedResource + "_content")){
		$(idOfResizedResource + "_content").setStyle({width:newXaResize + "px"});
	}
	if ($(idOfResizedResource + "_contentVideo")){
		$(idOfResizedResource + "_contentVideo").setStyle({width:newXbResize + "px"});
		$(idOfResizedResource + "_contentVideo").setStyle({height:newYbResize + "px"});
	}
    posXResize = ResizeEvent.clientX;
    posYResize = ResizeEvent.clientY;
    
    }

}
		
/**
* End of resizing. Called by onmouseup().
*/
function resize3(){
	hoveringActivated = true;
	isMouseDownOnSearchResult = false;
	mousedown = 0;
	idOfResizedResource = 0;
}


function test(e){

}
//-->
</script>